import java.util.Scanner;

public class Palindrome {
    public static boolean isPalindrome(String str) {
        int left = 0, right = str.length() - 1;
        while (left < right) {
            if (str.charAt(left) != str.charAt(right)) {
                return false;
            }
            left++;
            right--;
        }
        return true;
    }

    public static String makePalindrome(String str) {
        if (isPalindrome(str)) {
            return str;
        }

        StringBuilder prefix = new StringBuilder();
        for (int i = 0; i < str.length(); i++) {
            if (isPalindrome(str.substring(0, str.length() - i))) {
                break;
            }
            prefix.append(str.charAt(str.length() - 1 - i));
        }

        return prefix + str;
    }

    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        System.out.println("请输入字符串：");
        String input = scanner.nextLine();

        String result = makePalindrome(input);
        System.out.println("变为回文后的字符串：" + result);
    }
}
